package cn.ecut.service.impl;

import cn.ecut.dao.LoudongDao;
import cn.ecut.model.Loudong;
import cn.ecut.service.LoudongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.List;


@Service
public class LoudongServiceimpl implements LoudongService {
    @Autowired
    private LoudongDao loudongDao;

    @Override
    public List<Loudong> selectAll() {
        return loudongDao.selectAll();
    }

    @Override
    public int selectAllcount() {
        return loudongDao.selectAllcount();
    }

    @Override
    public int insert(Loudong loudong) {
        return loudongDao.insert(loudong);
    }

    @Override
    public String selectQuyuByXiangmubianma(String xiangmubianma) {
        return loudongDao.selectQuyuByXiangmubianma(xiangmubianma);
    }

    @Override
    public String getloudongBianma() {
        DecimalFormat decimalFormat=new DecimalFormat("00000");
        String s = loudongDao.selectThelast();
        s=s.substring(2);
        System.out.println(s);
        int i=Integer.parseInt(s)+1;
        String k=decimalFormat.format(i);
        String loudongBianma = "LD"+k;
        System.out.println(loudongBianma);
        return loudongBianma;
    }

    @Override
    public int deleteByPrimaryKey(String loudongbianma) {
        return loudongDao.deleteByPrimaryKey(loudongbianma);
    }

    @Override
    public int updateQiyongzhuangtai(Loudong loudong) {
        return loudongDao.updateQiyongzhuangtai(loudong);
    }

    @Override
    public List<Loudong> advanceSelect(String s) {
        return loudongDao.advanceSelect(s);
    }

    @Override
    public int updateByPrimaryKey(Loudong loudong) {
        return loudongDao.updateByPrimaryKey(loudong);
    }

}
